# 什么是序列？内容连续、有序，支持下标索引的一类数据容器
# 序列有哪些？列表、元组、字符串
#序列切片语法：序列[起始:结束:步长]
# 对list切片：从1开始到4结束（不包含4），步长为1（默认为1，可省略）
"""
my_list = [0,1,2,3,4,5,6,7,8]
result1 = my_list[1:4]
print(f"list切片后结果为：{result1}")

# 对tuple切片：从头到尾，步长为1    (都可以省略)
my_tuple = (0,1,2,3,4,5,6,7,8)
result2 = my_tuple[:]
print(f"tuple切片后结果为：{result2}")

# 对str切片：从头到尾，步长为2
my_str = "012345678"
result3 = my_str[: :2]
print(f"str切片后结果为：{result3}")

# 对str切片：从头到尾，步长为-1
my_str = "012345678"
result4 = my_str[: :-1]
print(f"str切片后结果为：{result4}")

# 对list切片：从6开始到1结束，步长为-1
my_list = [0,1,2,3,4,5,6,7,8]
result5 = my_list[6:1:-1]
print(f"list切片后结果为：{result5}")

# 对tuple切片：从头到尾，步长为-2
my_tuple = (0,1,2,3,4,5,6,7,8)
result6 = my_tuple[: :-2]
print(f"tuple切片后结果为：{result6}")
"""
# 综合练习
mystr = "liaogong,奇健李,号37"
# new_mystr = mystr[9:12]
new_mystr = mystr[-5:-8:-1]
print(f"结果1：{new_mystr}")
# result = new_mystr[::-1]
# print(f"最终结果：{result}")